package com.yiban.demo.Access.Entity;

import com.yiban.demo.Global.Entity.EntityGroup.NoNeedIdAccessGroup;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;

@NoArgsConstructor
@Data
@AllArgsConstructor
public class RestfulUri {
    @NotNull(message = "uri不能为空",groups = NoNeedIdAccessGroup.class)
    private String uri;
    @NotNull(message = "method不能为空",groups = NoNeedIdAccessGroup.class)
    private String method;

    @Override
    public int hashCode() {
        return uri.hashCode()+method.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof RestfulUri){
            RestfulUri restfulUri = (RestfulUri) obj;
            return restfulUri.hashCode() == hashCode()
                    && restfulUri.method.equals(method)
                    && restfulUri.uri.equals(uri);
        }
        return false;
    }
}
